package org.example.common;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;


public class ResponseEntity<T> implements Serializable {
    private static final long serialVersionUID = -613440566192132476L;
    private int code;
    private String message;
    private T data;

    public ResponseEntity() {}

    public ResponseEntity(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 快捷构造方法（可选）
    public static <T> ResponseEntity<T> success(T data) {
        return new ResponseEntity<>(200, "操作成功", data);
    }

    public static <T> ResponseEntity<T> fail(String message) {
        return new ResponseEntity<>(500, message, null);
    }

    public static <T> ResponseEntity<T> fail(int code, String message) {
        return new ResponseEntity<>(code, message, null);
    }

    // Getter & Setter
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
